
function SyncScroll(){
	return;
}

function SyncScroll2(){
	return;
}

function SyncScrollH(){
	if(arguments.length<2)return;
	for(var i = 1;i<arguments.length;i++){
		arguments[i].scrollLeft=arguments[0].scrollLeft;
	}
}

function SyncScrollV(){
	if(arguments.length<2)return;
	for(var i = 1;i<arguments.length;i++){
		arguments[i].scrollTop=arguments[0].scrollTop;
	}
}

var TRIM_PATTERN = /(^\s*)|(\s*$)/g;
String.prototype.trim = function() {
	return this.replace(TRIM_PATTERN, "");
}


function __blank(strValue) {
	if ( isElementsType(strValue)&& strValue.trim()!='') {
		return strValue;
	} else {
		return '';
	}
}

function WatrixLink(url, query, target, style) {
	if ( __blank(url)=='' ) { url = ''; }
	if ( __blank(query)!='' && query.indexOf('=')>0 ) {
		var params = query.split('&');
		var paramValues = new Array();
		for (var ii=0; ii<params.length; ii++ ) {
			var param = params[ii].split('=');
			paramValues[ii] = param[0] + '=' + encodeURI(param[1]);
		}
		query = '?' + paramValues.join('&');
	} else {
		query = '';
	}
	if ( __blank(target)=='' ) { target = ''; }
	if ( __blank(style)=='' )  { style  = ''; }

	window.open(url + query, target, style);
}

function fcBrTag(msg) {
	var loop = true;
	while (loop) {
		msg = msg.replace("</br>",'\n');
		if ( msg.indexOf("</br>")==-1 ) loop = false;
	}
	return msg;
}

function AllBluring(){
	if(event.srcElement.tagName=="A"||event.srcElement.tagName=="IMG")
		document.body.focus();
}
document.onfocusin = AllBluring;

function hstrlen(pstr) {
    var len = 0;
    if (pstr == null) return 0;
    for(var i=0; i<pstr.length; i++){
        len += byteLength(pstr.charAt(i));
    }
    return len;
}

function byteLength(chr) {
	var len = 0;
	var c = escape(chr);
	if (c.length == 1) len ++;
	else if (c.indexOf("%u") != -1) len += 2;
	else if (c.indexOf("%")  != -1) len += c.length/3;
	return len;
}

function isElementsType(item) {
	if (typeof(item) == "undefined" || item==null) {
		return false;
	}
	return true;
}

function nextElements(_form, _element) {
	if ( event.keyCode==13 ) {
		var v_element = _form.elements;
		for (var ii=0; ii<v_element.length-1; ii++) {
			if ( _element==v_element[ii] ) {
				v_element[ii+1].focus();
				break;
			}

		}
	}
}

function autoTab(thisObj, valLen , nextTabObj){ 
	if( thisObj.value.length==valLen ){
		nextTabObj.focus();
	}
}

function Wt(str) {
	document.write(str);
}

var IS_CHECK = true;
var NEXT_IDX = 0;
function chk_item() {
	var itemform = eval(document.e4NetForm.chk_box);
	if ( itemform ) {
		if ( itemform.length != null ) {
			for ( ii=0; ii<itemform.length; ii++) {
				itemform[ii].checked = IS_CHECK;
			}
		} else {
			itemform.checked = IS_CHECK;
		}
		IS_CHECK = !IS_CHECK;
	}
	return;
}

function add_item() {
	var replacText = (++NEXT_IDX%2==1) ? "DATA_BC" : "DATA_WC";
	var html = document.getElementById("DIV_ADD_ITEM").innerHTML.replace("{$CSS_CLASS}", replacText);
		html = html.replace("{$CSS_CLASS}", replacText);
	var TABLE_ROW = document.getElementById("TABLE_ITEMS").insertRow(1);
	var TABLE_COL = TABLE_ROW.insertCell();
		TABLE_COL.innerHTML = html;
	return;
}

function del_item() {
	var itemform = eval(document.e4NetForm.chk_box);
	if ( itemform ) {
		if ( itemform.length!=null ){
			for ( ii=0; ii<itemform.length; ii++ ) {
				if ( itemform[ii].checked==true){
					document.getElementById("TABLE_ITEMS").deleteRow(ii+1);
					ii--;
				}
			}
		} else if ( itemform.checked){
			document.getElementById("TABLE_ITEMS").deleteRow(1);
		}
	}
	return;
}

function isChecked(f) {
	var checkitem = 0;
	var _elements = eval(f.chk_box);
	if ( _elements ) {
		if ( _elements.length!=null ){
			for ( var ii=0; ii<_elements.length; ii++ ) {
				if ( _elements[ii].checked==true ) {
					checkitem++;
				}
				_elements[ii].value = ii;
			}
		} else {
			if ( _elements.checked==true ) {
				checkitem++;
				_elements.value = 0;
			}
		}
	}
	if ( checkitem==0 ) {
		return false;
	}
	return true;
}

function getCheckNumm(f) {
	var retvalue;
	var checkitem = 0;
	var _elements = eval(f.chk_box);
	if ( _elements ) {
		if ( _elements.length!=null ){
			for ( var ii=0; ii<_elements.length; ii++ ) {
				if ( _elements[ii].checked==true ) {
					retvalue = ii;
					checkitem++;
				}
			}
		} else {
			if ( _elements.checked==true ) {
				retvalue = 0;
				checkitem++;
			}
		}
	}
	if ( checkitem==0||checkitem>1 ) {
		retvalue = 9999;
	}
	return retvalue;
}

var WATRIX_ACCEPT_CHAR = "abcdefghijklmnopqrstuvwxyz0123456789_";
var WATRIX_NOTACCEPT_CHAR = "\\";
function isVar(str) {
	var chr = WATRIX_ACCEPT_CHAR;
	for (var ii=0; ii<str.length; ii++) {
		if (chr.indexOf(str.substring(ii, ii+1).toLowerCase())==-1) {
			return false;
		}
	}
	return true;
}

function isNotVar(str) {
	var chr = WATRIX_NOTACCEPT_CHAR;
	for (var ii=0; ii<str.length; ii++) {
		if (chr.indexOf(str.substring(ii, ii+1))>-1) {
			return true;
		}
	}
	return false;
}

function validatePath(str) {
	var idx = str.length;
	for ( var ii=0; ii<str.length; ii++ ) { 
		if ( str.substring(--idx)=='/' ) {
			str = str.substring(0, idx);
		}
	}
	return str;
}

function det_over_underline(obj) {
	obj.style.textDecoration = 'underline';
	obj.style.color = '#b51d1d';
}

function det_out_underline(obj) {
	obj.style.textDecoration = 'none';
	obj.style.color = '#000000';
}